< previous page page_94 next page >

Page 94
Now, update the BindControls procedure to link the checkbox control to the Contracted field in the Authors table. When you are done, your BindControls procedure should look like this:
Public Sub BindControls ()
   Dim cField1 As String
   Dim cField2 As String
   Dim cField3 As String
   '
   cField1 = "Name"
   cField2 = "AuID"
   cField3 = "Contracted"
   '
   Text1.DataField = cField1
   Label1.DataField = cField2
   Check1.DataField = cField3
End Sub
Save and run the project. You will see that some checkboxes are turned on, and some are turned off. You now have a bound checkbox control!
The Bound OLE Control
The Visual Basic OLE control has no database-related events or methods and only two database-related properties:
· DataSource
· DataField
Like the bound checkbox control, the OLE control has unique behaviors regarding displaying bound data. The OLE control is used to display OLE objects that are stored in an MDB file by Microsoft Access. This control cannot be used to display binary pictures saved directly to an MDB file by an application other than Access.
Now, let's add an OLE control to the form and bind it to a field in the Authors table. Drop an OLE control on the form and select the Cancel button in the Insert Object dialog box when you are prompted for the Object Type. Now, set the OLE control's DataSource property to Data1, and its SizeMode property to 1 Stretch. Refer to Figure 4.9 for control sizing and placement. We will bind this control to the Cover field with Visual Basic code in the following section, so, leave the DataField property empty.
After you add the control to the form, update the BindControls procedure to bind the OLE control to the Cover field in the Authors table. When you're done, the procedure should look like this:
Public Sub BindControls ()
   Dim cField1 As String
   Dim cField2 As String

 
< previous page page_94 next page >

If you like this book, buy it!